package com.anasoft.os.s4j;

import org.junit.runner.notification.RunListener;

import com.anasoft.os.s4j.annotation.ErrorReporting;
import com.thoughtworks.selenium.Selenium;

/**
 * Default implementation of the {@link SeleniumRunnerLogic} interface.
 * 
 * @see SeleniumRunnerLogic
 * 
 * @author vojtech.szocs
 */
public class DefaultSeleniumRunnerLogic implements SeleniumRunnerLogic {

    public static final SeleniumRunnerLogic INSTANCE = new DefaultSeleniumRunnerLogic();
    
    private DefaultSeleniumRunnerLogic() {}
    
    /**
     * @see com.anasoft.os.s4j.SeleniumRunnerLogic#getErrorReportingListener(com.anasoft.os.s4j.annotation.ErrorReporting, com.thoughtworks.selenium.Selenium)
     */
    public RunListener getErrorReportingListener(ErrorReporting errorConfig, Selenium session) {
        return new ErrorReportingListener(errorConfig, session);
    }
    
    /**
     * @see com.anasoft.os.s4j.SeleniumRunnerLogic#getSessionListener()
     */
    public SeleniumSessionListener getSessionListener() {
        return new SeleniumSessionListener() {
            
            public void afterSessionStarted(Selenium selenium) throws Exception {
                // empty
            }
            
            public void beforeSessionStopped(Selenium selenium) throws Exception {
                // empty
            }
            
        };
    }
    
}
